package jgl.vajra.driver.part.login.activity;

import android.text.TextUtils;

import jgl.vajra.driver.R;
import jgl.vajra.driver.databinding.ActivityLoginBinding;
import jgl.vajra.driver.manager.IntentManager;
import jgl.vajra.driver.part.login.contract.LoginContract;
import jgl.vajra.driver.part.login.viewModel.LoginViewModel;
import jgl.vajra.driver.utils.CountUtils;
import jgl.vajra.driver.widget.mvvm.factory.CreateViewModel;
import jgl.vajra.driver.widget.mvvm.view.BaseMVVMActivity;
import jgl.vajra.driver.widget.utils.ToastUtils;

@CreateViewModel(LoginViewModel.class)
public class LoginActivity extends BaseMVVMActivity<LoginViewModel, ActivityLoginBinding> implements LoginContract.View {

    private boolean isAgree = false;

    @Override
    public int getLayoutId() {
        return R.layout.activity_login;
    }

    @Override
    public void initData() {
        super.initData();
        mBinding.setView(this);
    }

    //取消
    @Override
    public void onDismiss() {
        IntentManager.toHomeActivity(LoginActivity.this);
    }

    //用户协议
    @Override
    public void onUserAgreement() {

    }

    //隐私政策
    @Override
    public void onPrivacyPolicy() {

    }

    //同意
    @Override
    public void onAgreeCheck() {
        isAgree = !isAgree;
        mBinding.ivAgreeStatus.setSelected(isAgree);
    }

    //获取验证码
    @Override
    public void onVerifyCode() {
        CountUtils.getCount(mBinding.tvVerifyCode);
    }

    @Override
    public void onLogin() {
      /*  if (!isAgree) {
            ToastUtils.showShort("请阅读并勾选下方协议");
            return;
        }

        String phone = mBinding.etPhone.getText().toString().trim();
        if (TextUtils.isEmpty(phone)) {
            ToastUtils.showShort("请输入正确的电话号码");
            return;
        }

        String verifyCode = mBinding.etVerifyCode.getText().toString().trim();
        if (TextUtils.isEmpty(verifyCode)) {
            ToastUtils.showShort("请输入验证码");
            return;
        }*/
        if (true)
            IntentManager.toRegisterActivity(LoginActivity.this);
        else
            IntentManager.toHomeActivity(LoginActivity.this);
    }
}
